package com.zw.weiyi.fragment;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.zw.weiyi.phonesms.R;
import com.zw.weiyi.util.MyApplication;


public class SettingFragment extends Fragment implements OnClickListener{
	
	private View view;//缓存页面
	private Button stBtn;
	private RelativeLayout iconlayout;
	private Context context;
	
	public SettingFragment(Context context){
		this.context = context;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		if(view==null){
			view=inflater.inflate(R.layout.setting_fragment,container, false);
		}
		ViewGroup parent = (ViewGroup) view.getParent();
		if(parent!=null){
			parent.removeView(view);//先移除
		}
		inintView(view);
		return view;
	}
	
	private void inintView(View view) {
		stBtn = (Button) view.findViewById(R.id.but);
		stBtn.setOnClickListener(this);
		iconlayout =(RelativeLayout) view.findViewById(R.id.iocn);
		iconlayout.setOnClickListener(this);

	}
	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.but://点击退出
			MyApplication.getInstance().AppExit();
			System.out.println("out");
			break;
		case R.id.iocn://点击退出
//			Intent intent = new Intent();
//			intent.setClass(SettingFragment.this);
//			startActivity(intent);
//			context.startActivity(new Intent(context, IconActivity.class));
			System.out.println("icon");
			break;

		default:
			break;
		}
	}
	
	
}
